body::-webkit-scrollbar {
    display: none;
}
html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.main {
    display: grid;
    height: 100%;
    width: 100%;
    grid-template-columns: calc(2 * var(--b-button)) 1fr var(--b-button) repeat(2, auto);
    grid-template-rows: auto var(--b-button);
    grid-column-gap: var(--o-padding);
    grid-row-gap: var(--o-padding);
    padding: var(--o-padding);
    box-sizing: border-box;
}

#top {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    grid-area: 1 / 1 / 2 / 6;
    border-radius: var(--border-radius);
    transition: var(--transition);
    position: relative;
}
#top:focus-within {
    box-shadow: var(--shadow);
}
#top:hover {
    box-shadow: var(--shadow);
}

#tab_bar {
    margin: 0 !important;
}
.main > div:not(:first-child) {
    display: flex;
    align-items: center;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}
.main > div:not(:first-child):hover {
    box-shadow: var(--shadow);
}

#text_out {
    box-sizing: border-box;
    transition: var(--transition);
    display: flex;
    flex: 1;
    border-radius: var(--border-radius);
    background: var(--bg);
    cursor: text;
    font-size: 1em;
    line-height: 1.5em;
    position: relative;
    height: 100%;
}
#line_num {
    margin: 0 8px;
    text-align: end;
    opacity: 0.3;
    cursor: default;
    user-select: none;
    position: relative;
}
#line_num > div {
    position: absolute;
    width: 100%;
}
#main_text {
    overflow: overlay;
    width: 100%;
    height: 100%;
    position: relative;
    -webkit-user-drag: none;
}
.text {
    position: relative;
    height: 100%;
    overflow: auto;
}
.text > * {
    position: absolute;
    top: 0;
    margin: 0;
    padding: 0;
    font-size: 1em;
    line-height: 1.5em;
    resize: none;
    height: max-content;
    font-family: sans-serif;
    border: none;
    overflow: hidden;
    letter-spacing: normal;
    word-spacing: normal;
    text-align: start;
    white-space: var(--wrap);
    overflow-wrap: break-word;
}
.text > textarea::selection {
    background-color: var(--hover-color);
}
.text > :not(textarea) {
    pointer-events: none;
    color: transparent;
}

.text .selection {
    background-color: var(--hover-color);
}

#text_bottom {
    grid-area: 2 / 1 / 3 / 3;
}
@keyframes blink {
    50% {
        opacity: 0;
    }
}
#composition {
    border-bottom: dotted var(--color) 1px;
    height: 1.3em;
}
#cursor {
    position: absolute;
    width: 0.1em;
    height: 1.5em;
    background: var(--color);
    background-size: cover;
    opacity: 0.2;
    overflow: hidden;
    z-index: 3;
    outline: none;
    color: #0000;
    white-space: nowrap;
    transition-duration: var(--cursor-a);
    transition-timing-function: linear;
    pointer-events: none;
}
#cursor:focus {
    opacity: 1;
    animation: 1s blink 3 steps(1);
    animation-iteration-count: infinite;
}
.cursor_insert {
    width: 0.3em !important;
}

#find_area {
    white-space: var(--wrap);
    position: absolute;
    top: 0px;
    color: #0000;
    user-select: none;
    font-size: 1em;
    line-height: 1.5em;
    margin: 8px 8px 8px 0;
    word-break: break-all;
}

/* 用于历史记录固定 */
.hover_b2 > button {
    background-color: var(--hover-color);
}

#history_list {
    transition: var(--transition);
    overflow-y: overlay;
    height: 100%;
    text-align: center;
    position: absolute;
    z-index: 9;
    top: 100%;
    width: 100%;
    background-color: var(--bg);
}
#history_list > div {
    margin: 0 0 16px 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: var(--bg);
    transition: var(--transition);
}
#history_list > div:hover {
    background-color: var(--hover-color);
    box-shadow: var(--shadow);
}
.history_title {
    height: 16px;
    padding: 4px;
    display: flex;
    justify-content: flex-end;
}
.history_title > button {
    height: 16px;
    width: 16px;
    padding: 0;
    margin-left: 4px;
    background-color: var(--hover-color);
    font-size: 16px;
    transition: var(--transition);
    border-radius: 50%;
}
.history_title > button > .icon {
    width: 16px;
}
.history_title > button:hover {
    background-color: #f00;
}
.history_title > button:hover > .icon {
    filter: invert(1);
}
.history_text {
    padding: 8px;
    text-align: start;
}

#edit_b {
    position: absolute;
    z-index: 3;
    border-radius: var(--border-radius);
    backdrop-filter: var(--blur);
    box-shadow: var(--shadow);
    font-size: 5px;
    overflow: hidden;
    cursor: pointer;
    background-color: var(--bar-bg);
    display: flex;
    top: 0;
}
.edit_h {
    opacity: 0;
    pointer-events: none;
}
.edit_s {
    opacity: 1;
    pointer-events: auto;
}
#edit_b > div {
    height: 30px;
    font-size: 30px;
    position: relative;
    transition: var(--transition);
}
#edit_b > div:not(:nth-child(1)) {
    width: 30px;
}
#edit_b > div:hover {
    background-color: var(--bar-hover-color);
}

#edit_b > div > .icon {
    width: 30px;
}
#link_bar {
    width: 0;
    overflow: hidden;
}

#find {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    background-color: var(--bg);
    transition: var(--transition);
    transform: translateY(-120%);
    box-shadow: var(--shadow);
    padding: 4px;
    border-bottom-left-radius: var(--border-radius);
}
#find > div {
    display: flex;
    align-items: center;
}
#count {
    grid-area: 1/ 1/ 2/ 2;
    font-size: 14px;
    margin-right: 8px;
    opacity: 0.5;
}
.find_buttons {
    grid-area: 1 / 3 / 2 / 4;
}
.find_f {
    grid-area: 1 / 2 / 2 / 3;
}
.find_s {
    grid-area: 2 / 2 / 3 / 3;
}
.find_t > span {
    font-size: 14px;
    font-family: var(--monospace);
}
#find button {
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 4px;
    font-size: 20px;
    position: relative;
}
#find button > .icon {
    width: 20px;
}
#find input {
    border: none;
    background-color: var(--bar-color);
    backdrop-filter: var(--blur);
    border-radius: 4px;
}
.find_h {
    background-color: var(--hover-color);
    border-radius: 2px;
}
.find_h_h {
    background-color: #00000040;
}

button {
    border-radius: 0;
    background-color: var(--bg);
    height: var(--height);
    border: none;
    outline: none;
    margin: 0px;
    color: var(--color);
    padding: 0;
    transition: var(--transition);
    cursor: pointer;
    background-position: center;
    background-size: cover;
    width: var(--b-button);
    height: var(--b-button);
    position: relative;
}
button:hover {
    background-color: var(--hover-color);
}
select {
    border-radius: 0;
    background-color: var(--bg);
    height: var(--height);
    border: none;
    outline: none;
    margin: 0px;
    color: var(--color);
    font-size: var(--font-size);
    padding: 0 var(--o-padding) 0 var(--o-padding);
    transition: var(--transition);
    user-select: none;
}
select:hover {
    background-color: var(--hover-color);
}
option {
    font-size: var(--font-size);
    background-color: var(--bg);
}
button > .icon {
    width: var(--b-button);
}

@media (prefers-color-scheme: dark) {
    .find_h_h {
        background-color: #ffffff40;
    }
}

#tabs {
    display: flex;
    margin: 0;
    padding: 0;
    overflow-x: scroll;
    opacity: 0;
    pointer-events: none;
}
#tabs::-webkit-scrollbar {
    display: none;
}

.tabs_show {
    opacity: 1 !important;
    pointer-events: all !important;
}

#buttons {
    display: flex;
    position: sticky;
    left: 0;
    z-index: 3;
    border-radius: var(--border-radius);
    overflow: hidden;
}
#buttons > div {
    cursor: pointer;
    width: var(--b-button);
    height: var(--b-button);
    transition: var(--transition);
    background-color: var(--bg);
    position: relative;
}
#buttons > div:hover {
    background-color: var(--hover-color);
    box-shadow: var(--shadow);
}
#buttons > div > .icon {
    width: var(--b-button);
}

.b_tab {
    display: flex;
    height: var(--b-button);
    align-items: center;
    flex: 1;
    max-width: 200px;
    justify-content: space-between;
    transition: var(--transition);
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
}
.b_tab:hover {
    background-color: var(--hover-color);
    box-shadow: var(--shadow);
}
.tab_focus {
    background-color: var(--hover-color);
}
.tab_small {
    max-width: 32px !important;
}
.tab_gray > img {
    filter: grayscale(1);
}

.b_tab > img {
    height: 20px;
    margin-left: 6px;
}
.loading {
    animation: loading 0.8s linear 0s infinite;
}
@keyframes loading {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.b_tab > span {
    cursor: default;
    padding-left: 4px;
    overflow: hidden;
    white-space: nowrap;
    flex-grow: 1;
}
.b_tab > button {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background: none;
    border: none;
    border-radius: 4px;
    transition: var(--transition);
    margin: 2px;
    padding: 0;
    position: relative;
}

.b_tab > button > .icon {
    width: 20px;
}

.b_tab > button:hover {
    background-color: var(--hover-color);
    box-shadow: var(--shadow);
}

.fill_t {
    background-color: var(--bg);
}

.fill_t #browser_bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100vh - 48px);
    background-color: var(--bg);
    pointer-events: none;
    z-index: 10;
    opacity: 0;
}

.fill_t_s #browser_bg {
    opacity: 1;
}
.fill_t_s .main {
    grid-template-columns: calc(2 * var(--b-button)) 1fr repeat(2, auto);
}
.fill_t_s #top {
    grid-area: 1 / 1 / 2 / 5;
}
.fill_t_s .main > #history {
    display: none;
}
